﻿@using KRM.Core
@model KRM.Core.tblEmail

@{
    var ListFirstEmail = ViewBag.ListFirstEmail as List<tblEmail>;
    var ConversionIDEmailHistory = ViewBag.ConversionIDEmailHistory as Dictionary<int, List<tblEmail>>;
}

@if (@Model != null)
{
    <div class="panel panel-primary">
            <div class="panel-heading ">
                <p>Original Email</p><hr />
                <div class="row-fluid">
                    <div class="span3">
                        From: @Model.From                     
                    </div>   
                    </div>     
                <div class="row-fluid">
                    <div class="span3">To: @Model.To</div>        
                </div>
                 <div class="row-fluid">
                    <div class="span3">CC: @Model.Cc</div>        
                </div>
                 <div class="row-fluid">
                    <div class="span3"><h4>@Model.Subject</h4></div>        
                </div>    
            </div>
        <div class="row-fluid panel-body">
            <div class="">
                            @Html.Raw(@Model.Body)
                <form action="/EmailTicket/EmailDetails" method="POST" class="row-fluid fr-linktoticket123">            
                    </form>
            </div>    
       </div>    
    </div>
}
<p style="font-size:20px;">List emails <small>(expand to view all email history)</small></p>

@foreach (var firstEmail in ListFirstEmail)
{
    <div class="portlet box blue">
        <div class="portlet-title">
            <div class="caption">
                <label>From: @firstEmail.From</label><br>
                                                     <label>Subject: @firstEmail.Subject</label>
                                                
            </div>
            <div class="tools">
                                    
                <a href="javascript:;" class="expand"></a>
            </div>
            <div class="row-fluid span3"> <a class="btn btn green" style="float:right;">hehe</a></div>
        </div>
        <div class="portlet-body" style="display: none;">
            @foreach (var email in ConversionIDEmailHistory[(int)firstEmail.ConversionID])
            {
                <div class="row-fluid">
                    @if (email.IsIncommingEmail != true)
                    {
                        <div style="float:right; width:650px;" class="panel panel-info">
                            <div class="panel-heading">
                                <div class="span3">From: @email.From <label style="float:right">@email.Date</label></div>
                                To: @email.To<br />
                                Subject: @email.Subject
                            </div>
                            <div class="panel-body">@Html.Raw(@email.Body)</div>
                        </div>
                    }
                    else
                    {
                        <div style="float:left; width:650px;" class="panel panel-success">
                            <div class="panel-heading">
                                <div class="span3">From: @email.From <label style="float:right">@email.Date</label></div>
                                To: @email.To<br />
                                Subject: @email.Subject </div>
                            <div class="panel-body">@Html.Raw(@email.Body)</div>
                        </div>
                    }
                </div>
            }     
        </div>
    </div>
}